<template>
  <div>
    <el-row :gutter="15">
      <el-form ref="elForm" :model="formData" :rules="rules" size="medium" label-width="100px">
        <el-col :span="11">
          <el-form-item label="listData" prop="listData">
            <el-input v-model="formData.listData" type="textarea" placeholder="请输入列表数据" rows="15" style="weight:75%;"
                      :autosize="{minRows: 15, maxRows: 15}" :style="{width: '100%'}"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="11">
          <el-form-item label="分隔符" prop="separatorChars">
            <el-input v-model="formData.separatorChars" placeholder="请输入分隔符" clearable :style="{width: '100%'}">
            </el-input>
          </el-form-item>
        </el-col>
        <el-col :span="11">
          <el-form-item label="内容符" prop="contentSignChars">
            <el-input v-model="formData.contentSignChars" placeholder="请输入内容符" clearable :style="{width: '100%'}">
            </el-input>
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item>
            <el-button size="medium" type="primary" @click="submitForm">提交</el-button>
            <el-button @click="resetForm">重置</el-button>
          </el-form-item>
        </el-col>
      </el-form>
    </el-row>
  </div>
</template>
<script>
    import {mapGetters} from 'vuex'
    import {getToken} from '@/utils/auth'
    import checkPermission from '@/utils/permission'
    import initData from '@/mixins/initData'
    import {parseTime, downloadFile} from '@/utils/index'
    import {listConvertLine} from '@/api/data-tools'
    import {downloadFileFunction} from '@/api/downloadFile'

    export default {
        components: {},
        props: [],
        data() {
            return {
                formData: {
                    listData: '',
                    separatorChars: '^r^n',
                    contentSignChars: '\''
                },
                rules: {
                    sql: [{
                        required: true,
                        message: '请输入列表数据',
                        trigger: 'blur'
                    }],
                },
            }
        },
        computed: {},
        watch: {},
        created() {
        },
        mounted() {
        },
        methods: {
            submitForm() {
                this.$refs['elForm'].validate(valid => {
                    if (!valid) return;
                    const listData = this.formData.listData;
                    const separatorChars = this.formData.separatorChars;
                    const contentSignChars = this.formData.contentSignChars;
                    console.log(listData);
                    console.log(separatorChars);
                    let params = {
                        listData: listData,
                        separatorChars: separatorChars,
                        contentSignChars: contentSignChars
                    };
                    listConvertLine(params).then(res => {
                        this.formData.listData = res.data;
                        this.$notify({
                            title: '处理成功',
                            type: 'success',
                            duration: 2500
                        });


                    }).catch(err => {
                        console.log(err);
                    });
                })
            },
            resetForm() {
                this.$refs['elForm'].resetFields()
            },
        }
    }

</script>
<style>
</style>
